home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / c / qtools0.2-src.lha / src / util / qview.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-15  |  1.3 KB  |  76 lines

  1. #define    LIBQTOOLS_CORE
  2. #define    LIBQBUILD_CORE
  3. #include <libqtools.h>
  4. #include <libqbuild.h>
  5.  
  6. struct memory bspStatic;
  7. struct memory *bspMem = &bspStatic;
  8.  
  9. int main(int argc, char **argv)
  10. {
  11.   char *fileName;
  12.   int width, height, depth;
  13.  
  14. #if defined(DEBUG_C) && defined(HAVE_LIBDBMALLOC)
  15.   union dbmalloptarg m;
  16.  
  17.   m.i = M_HANDLE_IGNORE;
  18.   dbmallopt(MALLOC_FATAL, &m);
  19. #endif
  20.  
  21.   if (argc == 1)
  22.     return 10;
  23.   else {
  24.     fileName = argv[1];
  25.  
  26.     if (argc <= 3) {
  27.       width = 320;
  28.       height = 200;
  29.     }
  30.     else {
  31.       width = atoi(argv[2]);
  32.       height = atoi(argv[3]);
  33.     }
  34.  
  35.     if (argc > 4)
  36.       depth = atoi(argv[4]);
  37.     else
  38.       depth = DRIVER_DEFAULT;
  39.   }
  40.  
  41.   if (!(
  42. #ifdef    DRIVER_8BIT
  43.      (depth == 8) ||
  44. #endif
  45. #ifdef    DRIVER_16BIT
  46.      (depth == 16) ||
  47. #endif
  48. #ifdef    DRIVER_24BIT
  49.      (depth == 24) ||
  50. #endif
  51. #ifdef    DRIVER_32BIT
  52.      (depth == 32) ||
  53. #endif
  54.      0)) {
  55.     eprintf("unsupported depth choosen\n");
  56.     return 10;
  57.   }
  58.  
  59.   display = DISPLAY_WIRE;
  60.  
  61.   if (!setjmp(eabort)) {
  62.     HANDLE bspFile;
  63.  
  64.     if ((bspFile = __open(fileName, H_READWRITE_BINARY_OLD)) > 0) {
  65.       if ((bspMem = LoadBSP(bspFile, ALL_QUAKE1_LUMPS | ALL_MAPS, BSP_VERSION_Q1))) {
  66.     PrintClusters(bspMem, 0, FALSE);
  67.     DisplayBSP(bspMem, width, height, depth, display);
  68.     FreeClusters(bspMem, 0);
  69.       }
  70.       __close(bspFile);
  71.     }
  72.   }
  73.  
  74.   return 0;
  75. }
  76.